<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <ul>
        <li>我是LI</li>
        <li>我是LI</li>
        <li>我是LI</li>
        <P>我是P</P>
    </ul>
    <button>添加</button>
    <script>
        document.querySelector("button").addEventListener('click', function (event) {
            var liDom = document.createElement('li')
            liDom.innerHTML = "未来元素"
            document.querySelector("ul").appendChild(liDom)
        })
        let ulDom = document.querySelectorAll('li')
        ulDom.forEach(function (item) {
            item.addEventListener('click', function () {
                alert(this.innerHTML)
            })
})
    </script>
</body>

</html>